package app.fugema.shop.main.online.vm;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;
import app.fugema.shop.main.home.model.NearStoreResult;

import com.base.common.netBeanPackage.BaseApiResult;
import com.base.common.netBeanPackage.LiveDataWrapper;
import com.base.common.utils.UIUtils;
import com.base.common.viewmodel.BaseViewModel;
import app.fugema.shop.http.HttpService;

import java.util.HashMap;
import java.util.Map;

public class OnlineVM extends BaseViewModel {

    public OnlineVM(@NonNull Application application) {
        super(application);
    }


    /**
     * 检查app 更新
     * @param appVersion
     * @return
     */
    public MutableLiveData<LiveDataWrapper<BaseApiResult>> updateApp(String appVersion )
    {
        return send(HttpService.getHttpServer().updateApp(appVersion,2));
    }

    /**
     * 查询 附近店铺列表
     * @param pageNo
     * @param lat
     * @param lng
     * @param userKey
     * @return
     */
    public MutableLiveData<LiveDataWrapper<NearStoreResult>> queryNearStoreList(int pageNo, double lat, double lng, String userKey )
    {
        Map<String,Object> params = new HashMap<>();

        params.put( "pageNo", pageNo);
        params.put( "pageSize", 5);
        params.put( "fromLatLng", lat+","+lng);
        if(UIUtils.isNotEmpty( userKey ))
        {
            params.put( "userkey", userKey);
        }
        //pageNo=1&pageSize=5& fromLatLng=24.87966,102.83322 &userkey=ZitrKzZY
        return send(HttpService.getHttpServer().getNearStoreList(params));
    }



}
